package com.tac.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.dao.EnergyEfficiencyDao;
import com.tac.pojo.EnergyEfficiency;
import com.tac.service.EnergyEfficiencyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EnergyEfficiencyServiceImpl implements EnergyEfficiencyService {

    @Autowired
    private EnergyEfficiencyDao energyEfficiencyDao;

    //查看能效预警
    public Result<PageInfo<EnergyEfficiency>> getList(Integer pageNum,Integer pageSize,String name, String add, Integer status){
        PageHelper.startPage(pageNum, pageSize);
        List<EnergyEfficiency> list = energyEfficiencyDao.getList(name, add, status);
        PageInfo<EnergyEfficiency> energyEfficiencyPageInfo = new PageInfo<>(list);
        return Result.success(energyEfficiencyPageInfo);
    }
    //添加能效预警
    public Result save(EnergyEfficiency energyEfficiency){
        Integer integer = energyEfficiencyDao.save(energyEfficiency);
        if(integer<=0){
            return Result.error("添加失败");
        }
        return Result.success(null);
    }
    //删除能效预警
    public Result remove(List<Integer> ids){
        Integer integer = energyEfficiencyDao.remove(ids);
        if(integer<=0){
            return Result.error("删除失败");
        }
        return Result.success(null);
    }

    //更新能效预警
    public Result update(EnergyEfficiency energyEfficiency){
        Integer integer = energyEfficiencyDao.update(energyEfficiency);
        if(integer<=0){
            return Result.error("更新失败");
        }
        return Result.success(null);
    }
}
